<template>
	<view>
		<view class="form">
			<view class="form-item">
				<input placeholder="请输入手机号码" v-model="form.mobile"/>
			</view>
			<view class="form-item">
				<input placeholder="请输入推荐人账号" v-model="form.tjuser"/>
			</view>
			<view class="form-item">
				<input placeholder="请输入姓名昵称" v-model="form.nickname"/>
			</view>
			<view class="form-item">
				<input placeholder="请输入登录密码" type="password" v-model="form.pwd"/>
			</view>
			<view class="form-item">
				<input placeholder="请确认登录密码" type="password" v-model="form.repwd"/>
			</view>
			<view class="form-item">
				<input placeholder="请输入交易密码" type="password" v-model="form.pwd1"/>
			</view>
			<view class="form-item">
				<input placeholder="请确认交易密码" type="password" v-model="form.repwd1"/>
			</view>
			<view class="form-item">
				<button @tap="submit()">立即注册</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				form : {
					mobile : '',
					nickname : '',
					tjuser : '',
					pwd : '',
					pwd1 : '',
					repwd : '',
					repwd1 :''
				}
			}
		},
		methods:{
			submit(){
				if(!this.form.mobile)return this.toasts('手机号码不能为空');
				if(!this.form.nickname)return this.toasts('昵称不能为空');
				if(!this.form.tjuser)return this.toasts('推荐人不能为空');
				if(!this.form.pwd)return this.toasts('登录密码不能为空');
				if(!this.form.pwd1)return this.toasts('交易密码不能为空');
				if(this.form.pwd != this.form.repwd)return this.toasts('两次登录密码不相等');
				if(this.form.pwd1 != this.form.repwd1)return this.toasts('两次交易密码不相等');
				this.ajax('login/reg',{
					data:this.form,
					success:(res) => {
						res = res.data;
						this.toasts(res.info);
						if(res.status) {
							setTimeout(()=>{
								uni.navigateBack({})
							},2000)
						}
					}
				})
			}
		}
	}
</script>

<style>
	.form{position:absolute;width: 80%;left:10%;top:0;}
	.form-item{margin-top: 40upx;}
	.form-item input{width: 100%;height:80upx;border-bottom:1upx solid #aaa;border-radius: 10upx;font-size: 30upx;padding-left: 20upx;color:#AAAAAA}
	.form-item button{height:80upx;line-height: 80upx;background: #409EFF;color:#FFFFFF}
</style>
